﻿<UserControl x:Class="AphidUI.AphidWatch"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:l="clr-namespace:AphidUI"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <l:BoolFlipConverter x:Key="flipConverter" />
    </UserControl.Resources>
    <DataGrid ScrollViewer.CanContentScroll="False" Background="Transparent"
              IsEnabled="{Binding IsExecuting,Converter={StaticResource flipConverter}}"
              ItemsSource="{Binding Expressions}" AutoGenerateColumns="False">
        <DataGrid.Columns>
            <DataGridTemplateColumn Header="Expression" Width="135">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <l:CodeViewer Code="{Binding Expression}" 
                                          IsHitTestVisible="False" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
                <DataGridTemplateColumn.CellEditingTemplate>
                    <DataTemplate>
                        <TextBox Text="{Binding Expression,Mode=TwoWay}"
                                     FocusManager.FocusedElement="{Binding RelativeSource={RelativeSource Self}}"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellEditingTemplate>
            </DataGridTemplateColumn>

            <DataGridTemplateColumn Header="Value" IsReadOnly="True" Width="135">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <l:CodeViewer Code="{Binding Value}" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>
    </DataGrid>
</UserControl>
